<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: CourseDependency</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">CourseDependency</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/models/course_dependency_rb.html">
                app/models/course_dependency.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                ActiveRecord::Base
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000072">course_is_in_earlier_semester?</a>&nbsp;&nbsp;
      <a href="#M000069">is_satisfied?</a>&nbsp;&nbsp;
      <a href="#M000070">is_satisfied_helper?</a>&nbsp;&nbsp;
      <a href="#M000068">to_s</a>&nbsp;&nbsp;
      <a href="#M000071">to_s_helper</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000069" class="method-detail">
        <a name="M000069"></a>

        <div class="method-heading">
          <a href="#M000069" class="method-signature">
          <span class="method-name">is_satisfied?</span><span class="method-args">(semester_id, user)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns whether this dependency has been satisfied for the specified
<tt>semester_id</tt>, and <tt>user</tt>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000069-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/course_dependency.rb, line 23</span>
23:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_satisfied?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
24:     <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
25:       <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">is_satisfied_helper?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
26:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
27:       <span class="ruby-keyword kw">end</span>
28:     <span class="ruby-keyword kw">end</span>
29: 
30:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
31:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000068" class="method-detail">
        <a name="M000068"></a>

        <div class="method-heading">
          <a href="#M000068" class="method-signature">
          <span class="method-name">to_s</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns a textual representation of this course&#8216;s dependencies
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000068-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/course_dependency.rb, line 6</span>
 6:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
 7:     <span class="ruby-identifier">courses</span> = []
 8:     <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">courses</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">to_s_helper</span> }
 9:     
10:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:CONCURRENT</span>
11:       <span class="ruby-keyword kw">return</span> <span class="ruby-value str">&quot;concurrently with &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">courses</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; and &quot;</span>)
12:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">node_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:OR</span>
13:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">courses</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; or &quot;</span>)
14:     <span class="ruby-keyword kw">end</span>
15:     
16:     <span class="ruby-comment cmt">#type is either COURSE or AND</span>
17:     
18:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">courses</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; and &quot;</span>)
19:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000072" class="method-detail">
        <a name="M000072"></a>

        <div class="method-heading">
          <a href="#M000072" class="method-signature">
          <span class="method-name">course_is_in_earlier_semester?</span><span class="method-args">(max_semester_id, user)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns whether the current node of type COURSE can be found in an earlier
semester than <tt>max_semester_id</tt> for <tt>user</tt>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000072-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/course_dependency.rb, line 71</span>
71:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">course_is_in_earlier_semester?</span>(<span class="ruby-identifier">max_semester_id</span>, <span class="ruby-identifier">user</span>)
72:     <span class="ruby-identifier">raise</span> <span class="ruby-constant">TypeError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">node_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:COURSE</span>
73: 
74:     <span class="ruby-identifier">user</span>.<span class="ruby-identifier">semesters</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">semester</span><span class="ruby-operator">|</span>
75:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">semester</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">max_semester_id</span>
76:         <span class="ruby-keyword kw">break</span>
77:       <span class="ruby-keyword kw">end</span>
78:       <span class="ruby-identifier">semester</span>.<span class="ruby-identifier">cis_courses</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">course</span><span class="ruby-operator">|</span>
79:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">course</span>.<span class="ruby-identifier">course_dependency</span>.<span class="ruby-identifier">id</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">id</span>
80:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
81:         <span class="ruby-keyword kw">end</span>
82:       <span class="ruby-keyword kw">end</span>
83:     <span class="ruby-keyword kw">end</span>
84: 
85:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
86:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000070" class="method-detail">
        <a name="M000070"></a>

        <div class="method-heading">
          <a href="#M000070" class="method-signature">
          <span class="method-name">is_satisfied_helper?</span><span class="method-args">(semester_id, user)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000070-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/course_dependency.rb, line 34</span>
34:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_satisfied_helper?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
35:     <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">node_type</span>
36:       <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:COURSE</span>
37:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">course_is_in_earlier_semester?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>) 
38:       <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:OR</span>
39:         <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
40:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">is_satisfied_helper?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
41:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
42:           <span class="ruby-keyword kw">end</span>
43:         <span class="ruby-keyword kw">end</span>
44:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">children</span>.<span class="ruby-identifier">empty?</span>
45:       <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:AND</span>
46:         <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
47:           <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">is_satisfied_helper?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
48:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
49:           <span class="ruby-keyword kw">end</span>
50:         <span class="ruby-keyword kw">end</span>
51:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
52:       <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#:CONCURRENT</span>
53:         <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
54:           <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">is_satisfied_helper?</span>(<span class="ruby-identifier">semester_id</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">user</span>)
55:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
56:           <span class="ruby-keyword kw">end</span>
57:         <span class="ruby-keyword kw">end</span>
58:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
59:     <span class="ruby-keyword kw">end</span>
60:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000071" class="method-detail">
        <a name="M000071"></a>

        <div class="method-heading">
          <a href="#M000071" class="method-signature">
          <span class="method-name">to_s_helper</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000071-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/course_dependency.rb, line 62</span>
62:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s_helper</span>
63:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">node_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:COURSE</span>
64:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cis_courses</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>
65:     <span class="ruby-keyword kw">end</span>
66:     
67:     <span class="ruby-keyword kw">return</span> <span class="ruby-value str">&quot;(&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;)&quot;</span>
68:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>